@import '../core/style/private';
@import '../core/theming/palette';
@import '../core/theming/theming';
@import '../core/theming/private';
@import '../core/typography/typography-utils';


@mixin mat-menu-color($config-or-theme) {
  $config: mat-get-color-config($config-or-theme);
  $background: map-get($config, background);
  $foreground: map-get($config, foreground);

  .mat-menu-panel {
    @include mat-private-theme-overridable-elevation(4, $config);
    background: mat-color($background, 'card');
  }

  .mat-menu-item {
    background: transparent;
    color: mat-color($foreground, 'text');

    &[disabled] {
      &, &::after {
        color: mat-color($foreground, 'disabled');
      }
    }
  }

  .mat-menu-item .mat-icon-no-color,
  .mat-menu-item-submenu-trigger::after {
    color: mat-color($foreground, 'icon');
  }

  .mat-menu-item:hover,
  .mat-menu-item.cdk-program-focused,
  .mat-menu-item.cdk-keyboard-focused,
  .mat-menu-item-highlighted {
    &:not([disabled]) {
      background: mat-color($background, 'hover');
    }
  }
}

@mixin mat-menu-typography($config-or-theme) {
  $config: mat-get-typography-config($config-or-theme);
  .mat-menu-item {
    font: {
      family: mat-font-family($config, body-1);
      size: mat-font-size($config, body-1);
      weight: mat-font-weight($config, body-1);
    }
  }
}

@mixin _mat-menu-density($config-or-theme) {}

@mixin mat-menu-theme($theme-or-color-config) {
  $theme: mat-private-legacy-get-theme($theme-or-color-config);
  @include mat-private-check-duplicate-theme-styles($theme, 'mat-menu') {
    $color: mat-get-color-config($theme);
    $density: mat-get-density-config($theme);
    $typography: mat-get-typography-config($theme);

    @if $color != null {
      @include mat-menu-color($color);
    }
    @if $density != null {
      @include _mat-menu-density($density);
    }
    @if $typography != null {
      @include mat-menu-typography($typography);
    }
  }
}

